<?php
/**
 * Created by JetBrains NetBeans.
 * User: yinyancai
 * Date: 13-3-14 下午4:44
 * To change this template use File | Settings | File Templates.
 */
if (!defined('IN_MOBILE_API')) {
    exit('Access Denied');
}
include_once 'forum.php';
class cloud_api {
    function common() { }

    function output() {
        global $_G;
        //判断是否缺少参数
        if (empty($_GET['token'])) {
            $variable = array(
                'code' => 1001,
                'messagestr' => lang('plugin/cloud', '1001'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }
        $res = C::t('#cloud#cloud_coupon')->fetch_info_token($_GET['token']);
        if(empty($res)){
            $variable = array(
                'code' => 90003,
                'messagestr' => lang('plugin/cloud', '90003'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }else{
            if($res['status'] == '0'){
                $variable = array(
                    'code' => 90004,
                    'messagestr' => lang('plugin/cloud', '90004'),
                );
                cloud_core::result(cloud_core::variable($variable));
            }else{

                if(time() > strtotime($res['time'])){
                    $variable = array(
                        'code' => 90005,
                        'messagestr' => lang('plugin/cloud', '90005'),
                    );
                    cloud_core::result(cloud_core::variable($variable));
                }else{
                    $status = array('status'=>0);
                    $data = C::t('#cloud#cloud_coupon')->update_token($_GET['token'],$status);

                    //正常返回
                    $variable = array(
                        'code' => 90002,
                        'messagestr' => lang('plugin/cloud', '90002'),
                    );
                    cloud_core::result(cloud_core::variable($variable));
                }
            }
        }
    }
}

?>

